// pages/tijiaorepair/tijiaorepair.js
const request = require("../../utils/request.js")
Page({

  /**
   * 页面的初始数据
   */
  data: {
    list1:[
      {id:1,image:"/static/img/sp.png",title:"咖啡机咖啡机1",text:"未报修",text2:"001",price:"200",price1:"500",button:"我要报修",button1:"删除",show1:'1'},
    ],
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {

  },
  tijiaorepair(total_id,total_name1,total_name2,total_name3) {
    // const _this = this
    console.log(total_id,total_name1,total_name2,total_name3);
    request.wxRequest('repair/add', function (err, data) {
      if (err) {
        // 失败；
        console.log(err)
        wx.showToast({
          title: '订单已维修',
          icon:'none'
        })
      } else {
        console.log(data)
        wx.showToast({
          title: '提交成功',
          icon:'none'
        })
      }
    }, 'POST', {
      order_id:total_id,
      name:total_name1,
      mobile:total_name2,
      remarks:total_name3,
      images:'https://img0.baidu.com/it/u=793140083,1864465658&fm=253&fmt=auto&app=138&f=JPEG?w=889&h=500',
    })
  },

  jump(e){
    //编号
    var total_id = e.detail.value.total_id;
    //姓名
    var total_name1 = e.detail.value.total_name1;
    //手机号
    var total_name2 = e.detail.value.total_name2;
    // 备注
    var total_name3 = e.detail.value.total_name3;
    console.log('姓名：'+total_name1)
    console.log('手机号:'+total_name2)
    console.log('备注'+total_name3)
    this.tijiaorepair(total_id,total_name1,total_name2,total_name3);
    wx.switchTab({
      url: '/pages/repair/repair',
    })
   },
  selectPicture(){
    wx.chooseMedia({
      count:9,
      mediaType:['image','video'],
      sourceType:"album",
      maxDuration:30,
    success:(res)=>{
      let i=0;
      var list=new Array
      for (i;i<res.tempFiles.length;i++){
        list.push(res.tempFiles[i].tempFilePath)
      }
      this.setData({
        lista:list
      })
      console.log(list)
    }
    })
  },
  handleSuccess(e) {
    const { files } = e.detail;
    this.setData({
      originFiles: files,
    });
  },
  handleRemove(e) {
    const { index } = e.detail;
    const { originFiles } = this.data;
    originFiles.splice(index, 1);
    this.setData({
      originFiles,
    });
  },
  handleClick(e) {
    console.log(e.detail.file);
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {

  }
})